﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
 Inherits="System.Web.Mvc.ViewPage<IntellectShop.Common.Course>" %>
<%@ Import Namespace="IntellectShop.Web2.Code" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%= Html.Resource("CourceDetails") %> - <%= Html.Encode(Model.Print()) %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
	<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
	<script type="text/javascript">
		function handleUpdate(context) {
			// Load and deserialize the returned JSON data
			var json = context.get_data();
			var data = Sys.Serialization.JavaScriptSerializer.deserialize(json);

			var cartName = '<%= Html.Resource("Strings, Cart") %>';
			$('#cart-status').text(cartName + ' (' + data.CartCount + ')');
		}

		function handleBegin() {
			var options = { to: "#cart-status", className: "ui-effects-transfer" };
			$("#addLinkParagraph a").effect("transfer", options, 500, callback);
		}

		function callback() {
			setTimeout(function () {
				$("#addLinkParagraph a").removeAttr("style").hide().fadeIn();
			}, 1000);
		};
	</script>

	<h1><%= Html.Resource("CourceDetails") %>:</h1>

	<p id="addLinkParagraph" class="button">
		<%= Ajax.ActionLink(Html.Resource("Strings, AddToCart"), "AddToCartAjax", "Cart", new { id = Model.CommodityID }, new AjaxOptions { HttpMethod="Post", OnBegin="handleBegin", OnSuccess = "handleUpdate" })%>
	</p>
	<p class="button">
		<% if (HttpContext.Current.User.IsInRole(IntellectShop.Common.Globals.AdministratorRoleName))
		{ %>
			<%= Html.ActionLink(Html.Resource("Edit"), "Edit", "Course", new { id = Model.CommodityID }, null)%>
		<% } %>
	</p>

	<%= Html.DisplayFor(model => Model)%>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FirstInfo" runat="server">
	<div class="sidebaritem">
		<% Html.RenderAction("Details", "Schedule", new { courseID = Model.CourseID }); %>
	</div>
</asp:Content>